package com.Tao.servlet;

import com.Tao.dao.UserDao;
import com.Tao.user.FirstPageJson;
import com.Tao.util.JDBCUtil;
import com.Tao.utils.MybatisUtils;
import org.apache.ibatis.session.SqlSession;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/userUpdateServlet")
public class userUpdateServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        resp.setContentType("text/html;charset=utf-8");
        String username = req.getParameter("title");
        String phone = req.getParameter("phone");
        String city = req.getParameter("city");
        String id = req.getParameter("id");
        String sex = req.getParameter("sex");
        String major = req.getParameter("major");
        String occupation = req.getParameter("occupation");
        String education = req.getParameter("education");
        String money = req.getParameter("money");
        JDBCUtil.getDML("UPDATE test_table set username =?,sex=?,phone=?,city=?,major=?,occupation=?,education=?,money=? where id=?", username, sex, phone, city, major, occupation, education, money, id);
        resp.sendRedirect(req.getContextPath()+"/crud/test.jsp");
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doGet(req, resp);
    }
}
